#!/bin/bash

PINDIR=/Users/sdhammo/Documents/PIN/2.13
CXX=clang++
LD=clang++
CC=clang
PREPROC=-DBIGARRAY_MULTIPLIER=1 -DTARGET_IA32E -DHOST_IA32E -fPIC -DTARGET_MAC -DPROSPERO_LIBZ
CXXFLAGS=-stdlib=libstdc++ -O3 -g -fomit-frame-pointer -fno-strict-aliasing

all: sstmemtrace.dylib

sstmemtrace.dylib: sstmemtrace.o
	$(LD) -shared \
		-w -Wl,-exported_symbols_list \
		-Wl,$(PINDIR)/source/include/pin/pintool.exp \
		-stdlib=libstdc++ \
		-L$(PINDIR)/extras/xed2-intel64/lib \
		-L$(PINDIR)/intel64/lib \
		-L$(PINDIR)/intel64/lib-ext \
		-o $@ $< \
		-L$(PINDIR)/extras/xed2-intel64/lib \
		-L$(PINDIR)/intel64/lib \
		-L$(PINDIR)/intel64/lib-ext -lpin -lxed -lpindwarf -lz

sstmemtrace.o: sstmemtrace.cc
	$(CXX) $(CXXFLAGS) -c \
	-I $(PINDIR)/source/include/pin \
	-I $(PINDIR)/source/include/pin/gen \
	-I $(PINDIR)/extras/xed2-intel64/include \
	-I $(PINDIR)/extras/components/include \
	$(PREPROC) \
	-o $@ \
	$<

clean:
	rm *.o sstmemtrace.so
